class Document
  include DataMapper::Resource
  storage_names[:default] = "Document"
  
  property :id,           Serial
  property :title,        String,        :required => true, :length => 500
  property :size,         Integer
  property :content_type, String,        :length => 500
  property :data,         Blob
  property :description,  String
  timestamps :at


  IMAGE = ["image/gif", "image/jpeg", "image/png"]
  TYPE = ["text/plain", "application/pdf", "application/zip", "application/vnd.ms-excel",
          "application/msword", "application/vnd.ms-powerpoint"]

  def document_file=(input_data)
    self.title = input_data.original_filename
    self.size = input_data.size
    self.content_type = input_data.content_type.chomp
    self.data = input_data.read
  end
end
